namespace RAG.Domain.ValueObjects;

/// <summary>
/// 头像信息值对象
/// </summary>
public class AvatarInfo
{
    public string Url { get; private set; }
    public string FileName { get; private set; }
    public long FileSize { get; private set; }
    public string ContentType { get; private set; }
    public DateTime UploadTime { get; private set; }
    public bool IsDefault { get; private set; }

    public AvatarInfo(string url, string fileName, long fileSize, string contentType, DateTime uploadTime, bool isDefault = false)
    {
        Url = url ?? throw new ArgumentNullException(nameof(url));
        FileName = fileName ?? throw new ArgumentNullException(nameof(fileName));
        FileSize = fileSize;
        ContentType = contentType ?? throw new ArgumentNullException(nameof(contentType));
        UploadTime = uploadTime;
        IsDefault = isDefault;
    }

    public static AvatarInfo CreateDefault()
    {
        return new AvatarInfo(
            "/api/users/avatar/default-avatar.png",
            "default-avatar.png",
            0,
            "image/png",
            DateTime.UtcNow,
            true
        );
    }

    public string GetFileSizeFormatted()
    {
        if (FileSize < 1024)
            return $"{FileSize} B";
        else if (FileSize < 1024 * 1024)
            return $"{FileSize / 1024.0:F1} KB";
        else
            return $"{FileSize / (1024.0 * 1024.0):F1} MB";
    }
} 